<?php

// GNU [A]GPLv+3 here

function PutFileList()
{
	if ( !isset($_FILES['0']) )
	{
		echo '400 You forgot to attach a mime-attachment with a file';
	}
	else
	{
		$ContentArchive	= stripslashes($_GET['ContentArchive']);

		if ( !file_exists('filelists') ) { mkdir('filelists'); }

		$FileName = $ContentArchive . '.filelist';

		$Destination = 'filelists/' . $FileName;

		$TempFile = $_FILES['0']['tmp_name'];

		if ( !isset($_GET['Append']) )
		{
			copy($TempFile, $Destination);

			// If everything went right, do output 'Success'
			echo "200 Successfully copied from $TempFile to $Destination!\n";
		}
		else
		{
			// Split-Upload support. Just append the next potion of data!
			file_put_contents($Destination, file_get_contents($TempFile), FILE_APPEND);

			// If everything went right, do output 'Success'
			echo "200 Successfully appended from $TempFile to $Destination!\n";
		}
	}
}

?>
